<?php
if(!defined('DCS_ROOT')) {exit('Access Denied');} 

class UserModel {
	var $DB;
	function UserModel ( $DB ){
		$this->DB = $DB;
	}

	function getUserbasic($uid){		
		$sql = "SELECT * FROM member WHERE uid = '$uid' ";
		$this->DB->query($sql);
		return $this->DB->fetchRow();	
	}

	function addReview($mid,$uid,$rating,$title,$contents,$ip,$addtime){
		$sql = "INSERT INTO member (mid,uid,rating,title,contents,ip,addtime) VALUES (
		'$mid','$uid','$rating','$title','$contents','$ip','$addtime')";
		$this->DB->query($sql);	
		return $this->DB->insertID();
	}
	
	function editUser($uid,$tel,$qq,$msn,$address,$sign){
		$sql = "UPDATE member SET tel='$tel',qq='$qq',msn='$msn',address='$address',sign='$sign' WHERE uid = '$uid'";
		$this->DB->query($sql);	
		return $this->DB->affectedRows();
	}

	function editAvatars($uid,$avatars){
		$sql = "UPDATE member SET avatars='$avatars' WHERE uid = '$uid'";
		$this->DB->query($sql);	
		return $this->DB->affectedRows();
	}

	function editPassword($uid,$pw,$newpw){
		$sql = "UPDATE member SET password = '$newpw' WHERE uid = '$uid' AND password = '$pw' ";
		$this->DB->query($sql);	
		return $this->DB->affectedRows();
	}
}

?>
